<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app"></div>
</body>
<script>
     //2、空对象继承
  function Person() {}
  Person.prototype.foot = 2
  Person.prototype.head = 1

  function Student(id, name) {
    console.log("Student的构造函数被调用")
    this.id = id
    this.name = name
    this.show = function() {
      return "{id=" + this.id + ",name=" + this.name + ",foot=" + this.foot + ",head=" + this.head + "}"
    }
  }

  //实现继承的函数
  function extend(Child, Parent) {
    let F = function() {}
    F.prototype = Parent.prototype
    Child.prototype = new F()
    Child.prototype.constructor = Child
  }
  extend(Student, Person)
  let stu = new Student(1, "tom")
  app.innerHTML = stu.show()
  console.log(stu.__proto__)
</script>
</html>